fix(sync): harden skill scanning against bad paths, reject filesystem-root plugin sources#440
Merged
Merged
Conversation
…-root plugin sources A user hit `EPERM: operation not permitted, scandir 'C:\$WinREAgent\...'` right after a successful `plugin uninstall`, on v1.13.2 (already past the #434 getHomeDir() fix). Root cause: their workspace.yaml had a corrupted plugin entry that was a bare `\`, which resolves to the drive root on Windows — walkForSkillMd (skills.ts) recursed into it unguarded (no try/catch, no symlink guard) and crashed the whole post-uninstall sync, even though uninstall itself had already succeeded. - walkForSkillMd now catches readdir errors and records a warning with remediation steps instead of throwing; also skips symlinks/junctions to avoid unbounded recursion through loops. Warnings thread through collectPluginSkills -> collectAllSkills/collectAvailableSkillNames -> SyncResult.warnings, deduplicated since the same bad plugin is scanned twice internally. - addPlugin/addUserPlugin now reject a local-path source that resolves to a filesystem root (new isFilesystemRoot helper), closing the entry point that let the bare `\` get written in the first place. - runUserSyncAndPrint (plugin.ts) was silently never printing the Warnings: section at all (unlike its project-scope sibling) - user-scope syncs were swallowing every warning, not just the new ones. Fixed to match runSyncAndPrint.
Deploying allagents with
|
| Latest commit: |
5dffc40
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1d429232.allagents.pages.dev |
| Branch Preview URL: | https://fix-433-skill-scan-eperm.allagents.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A user reported that
npx allagents plugin uninstall <plugin>printed✓ Uninstalled plugin (user scope): ...and then crashed withError: EPERM: operation not permitted, scandir 'C:\$WinREAgent\Scratch\Mount\Windows\System32\LogFiles\WMI\RtBackup'. They were already on v1.13.2 (past the #434getHomeDir()fix), so this was a different bug.Root cause: their
~/.allagents/workspace.yamlhad a corrupted plugin entry — a bare\— which resolves to the drive root on Windows.walkForSkillMd(the recursive skill scanner insrc/core/skills.ts) had no try/catch and no symlink guard (unlike its siblingdiscoverRepoSkillsinrepo-skills.ts), so it recursed unguarded intoC:\and crashed the entire post-uninstall sync — even though the uninstall itself had already succeeded, and even though the bad plugin wasn't the one being uninstalled (sync scans every installed plugin).walkForSkillMdhardening (src/core/skills.ts): catchesreaddirerrors and records a warning with remediation steps instead of throwing; skips symlinks/junctions to avoid unbounded recursion through loops. Warnings thread throughcollectPluginSkills→collectAllSkills/collectAvailableSkillNames→SyncResult.warnings, deduplicated since the same bad plugin gets scanned twice internally.src/utils/plugin-path.ts,workspace-modify.ts,user-workspace.ts):addPlugin/addUserPluginnow reject a local-path source that resolves to a filesystem root (newisFilesystemRoothelper) — closing the entry point that let the bare\get written in the first place. There's no legitimate use case for a plugin source that resolves to a drive/filesystem root.runUserSyncAndPrint(plugin.ts) never printed theWarnings:section at all (unlike its project-scope siblingrunSyncAndPrint) — user-scope syncs were silently swallowing every warning, not just the new ones.Test plan
bun test— new/extended unit tests inskills.test.ts,plugin-path.test.ts,sync-resilient.test.ts,workspace-modify.test.ts,user-workspace.test.tsall passbun run typecheckandbun run lintcleanbun run build,node dist/index.js ...):plugin uninstall <good-plugin> --scope usersucceeds, sync completes (exit 0), and prints exactly one deduplicated warning with remediation steps instead of crashing.plugin install "\"(both project and user scope) → rejected withPlugin source cannot be a filesystem root directory: \, exit 1,workspace.yamluntouched.